@extends('layout.home.index')

@section('css')
		<link href="/home/AmazeUI-2.4.2/assets/css/amazeui.css" rel="stylesheet" type="text/css" />
		<link href="/home/basic/css/demo.css" rel="stylesheet" type="text/css" />
		<link href="/home/css/cartstyle.css" rel="stylesheet" type="text/css" />
		<link href="/home/css/optstyle.css" rel="stylesheet" type="text/css" />

		<script type="text/javascript" src="/home/js/jquery.js"></script>
@endsection

@section('content')
<!--购物车 -->
			<div class="concent">
				<div id="cartTable">
					<div class="cart-table-th">
						<div class="wp">
							<div class="th th-chk">
								<div id="J_SelectAll1" class="select-all J_SelectAll">

								</div>
							</div>
							<div class="th th-item">
								<div class="td-inner">商品信息</div>
							</div>
							<div class="th th-price">
								<div class="td-inner">单价</div>
							</div>
							<div class="th th-amount">
								<div class="td-inner">数量</div>
							</div>
							<div class="th th-sum">
								<div class="td-inner">金额</div>
							</div>
							<div class="th th-op">
								<div class="td-inner">操作</div>
							</div>
						</div>
					</div>
					<div class="clear"></div>
					@foreach($goods as $key=>$value)
<<<<<<< HEAD
					<div class="a{{ $value['id'] }}">
=======
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
					<tr class="item-list shop">
						<div class="bundle  bundle-last ">
							<div class="bundle-hd">
								<div class="bd-promos">
									
									<div class="act-promo">
										<a href="#" target="_blank"><span class="gt"></span></a>
									</div>
									<span class="list-change theme-login">编辑</span>
								</div>
							</div>
							<div class="clear"></div>
							<div class="bundle-main">
								<ul class="item-content clearfix">
									<li class="td td-chk">
										<div class="cart-checkbox ">
<<<<<<< HEAD
											<input class="checked" id="J_CheckBox_170037950254" name="items[]" goods="{{ $value['goods_id'] }}" value="{{ $value['id'] }}" count="{{ $value['count'] }}" price="{{ $value['count_price'] }}"  type="checkbox">
=======
											<input class="checked" id="J_CheckBox_170037950254" name="items[]" value="{{ $value['id'] }}" price="{{ $value['count_price'] }}"  type="checkbox">
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
											<label for="J_CheckBox_170037950254"></label>
										</div>
									</li>
									<li class="td td-item">
									
										<div class="item-pic">
											<a href="#" target="_blank" data-title="美康粉黛醉美东方唇膏口红正品 持久保湿滋润防水不掉色护唇彩妆" class="J_MakePoint" data-point="tbcart.8.12">
												<!-- 商品图片 -->
												<img src="/images/admin/goods_pic/{{ $value['goods_datalist_pic1'] }}" class="itempic J_ItemImg" width="80" height="80"></a>
												<!-- 商品图片 -->
										</div>
									<!-- 商品简介 -->
										<div class="item-info">
											<div class="item-basic-info">
												<a href="#" target="_blank" title="美康粉黛醉美唇膏 持久保湿滋润防水不掉色" class="item-title J_MakePoint" data-point="tbcart.8.11">美康粉黛醉美唇膏 持久保湿滋润防水不掉色</a>
											</div>
										</div>
									<!-- 商品简介结束 -->
									</li>
									<!-- 商品配置 -->
									<li class="td td-info">
										<div class="item-props item-props-can">
<<<<<<< HEAD
											<span class="sku-line">{{ $value['goods_config_cpu_brand'] }} {{ $value['goods_config_cpu_type'] }}&nbsp;{{ $value['goods_config_ram_size'] }}/{{ $value['goods_config_disk_size'] }}</span>
=======
											<span class="sku-line"></span>
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
											<span class="sku-line"></span>
											
											<i class="theme-login am-icon-sort-desc"></i>
										</div>
									</li>
									<!-- 商品配置结束 -->

									<!-- 商品价格 -->
									<li class="td td-price">
										<div class="item-price price-promo-promo">
											<div class="price-content">
											<!-- 原价 -->
												<div class="price-line">
													<em class="price-original oldprice">{{ $value['old_price'] }}</em>
												</div>
											<!-- 原价结束 -->

											<!-- 现价 -->
												<div class="price-line">
													<em class="J_Price price-now nowprice" tabindex="0">{{ $value['goods_price'] }}</em>
												</div>
											<!-- 现价结束 -->
											</div>
										</div>
									</li>
									<!-- 商品价格结束 -->
									<li class="td td-amount">
										<div class="amount-wrapper ">
											<div class="item-amount ">
												<div class="sl">
													<input class="min am-btn" name="" type="button" value="-" />
													<!-- 商品默认数量 -->
<<<<<<< HEAD
													<input class="text_box count b{{ $value['id'] }}" name="" type="text" value="{{ $value['count'] }}" price="{{ $value['goods_price'] }}" style="width:30px;" />
=======
													<input class="text_box count" name="" type="text" value="{{ $value['count'] }}" price="{{ $value['goods_price'] }}" style="width:30px;" />
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
													<input class="add am-btn" name="" type="button" value="+" />
												</div>
											</div>
										</div>
									</li>
									<li class="td td-sum" id="conut_price">
									<!-- 商品总金额 -->
										<div class="td-inner">
											<em tabindex="0" class="J_ItemSum number count_price">{{ $value['count_price'] }}</em>
										</div>
									<!-- 商品总金额结束 -->	
									</li>
									<li class="td td-op">
										<div class="td-inner">
<<<<<<< HEAD
											<a href="javascript:;" data-point-url="#" class="delete" onclick="deleteCar('{{ $value['id'] }}')">
=======
											<a href="javascript:;" data-point-url="#" class="delete">
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
                  删除</a>
										</div>
									</li>
								</ul>				
							</div>
						</div>
					</tr>
<<<<<<< HEAD
					</div>
=======
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
					@endforeach
					<div class="clear"></div>

					
				</div>
				<div class="clear"></div>

				<div class="float-bar-wrapper">
					<div id="J_SelectAll2" class="select-all J_SelectAll">
						<div class="cart-checkbox">
<<<<<<< HEAD
							<input class="check" id="J_CheckBox_170037950254" value="28" price="12750" type="checkbox">

=======
							<input class="check-all check" id="J_SelectAllCbx2" name="select-all" value="true" type="checkbox">
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
							<label for="J_SelectAllCbx2"></label>
						</div>
						<span>全选</span>
					</div>
					<div class="operations">
						<a href="#" hidefocus="true" class="deleteAll">删除</a>
					</div>
					<div class="float-bar-right">
						<div class="amount-sum">
							<span class="txt">已选商品</span>
							<em id="J_SelectedItemsCount">0</em><span class="txt">件</span>
							<div class="arrow-box">
								<span class="selected-items-arrow"></span>
								<span class="arrow"></span>
							</div>
						</div>
						<div class="price-sum">
							<span class="txt">合计:</span>
							<strong class="price">¥<em id="J_Total">0.00</em></strong>
						</div>
						<div class="btn-area">
<<<<<<< HEAD
							<a href="javascript:void(0)" id="J_Go" class="submit-btn submit-btn-disabled" aria-label="请注意如果没有选择宝贝，将无法结算">
=======
							<a href="pay.html" id="J_Go" class="submit-btn submit-btn-disabled" aria-label="请注意如果没有选择宝贝，将无法结算">
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
								<span>结&nbsp;算</span></a>
						</div>
					</div>

				</div>

				

			</div>
<<<<<<< HEAD
			<div id="shop" style="display:none;"></div>
=======
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d

<script>

	price = 0;

// 全选
<<<<<<< HEAD
// $(".check").click(function(){ 
//   $("input[name='items[]']").each(function(){
// 	  if (this.checked) {
// 		  this.checked = false;
// 		  	// 获取商品总金额
// 			var count = parseInt($('#J_Total').text());
// 			// 获取商品单个的总额
// 			price = parseInt($(this).attr('price'));
// 			if(count != 0) {
// 				// 商品单个商品总额加上商品总额
// 			$('#J_Total').text(count-price);
// 			}
			
// 	  }else{
// 		  this.checked = true;
// 		  	// 获取商品总金额
// 			var count = parseInt($('#J_Total').text());
// 			// 获取商品单个的总额
// 			price = parseInt($(this).attr('price'));
// 			// 商品单个商品总额加上商品总额
// 			$('#J_Total').text(count+price);

// 	  }
//   });
// })

$('.check').click(function(){
	if($(this).attr('checked')) {
		$('.checked').attr('checked',true);
		// 获取商品总金额
			var count = parseInt($('#J_Total').text());
			// 获取商品单个的总额
			price = parseInt($(this).attr('price'));
			// 商品单个商品总额加上商品总额
			$('#J_Total').text(count+price);
	}else {
		$('.checked').attr('checked',false);
		// 获取商品总金额
=======
$(".check").click(function(){ 
  $("input[name='items[]']").each(function(){
	  if (this.checked) {
		  this.checked = false;
		  	// 获取商品总金额
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
			var count = parseInt($('#J_Total').text());
			// 获取商品单个的总额
			price = parseInt($(this).attr('price'));
			if(count != 0) {
				// 商品单个商品总额加上商品总额
			$('#J_Total').text(count-price);
			}
<<<<<<< HEAD
	}
})
=======
			
	  }else{
		  this.checked = true;
		  	// 获取商品总金额
			var count = parseInt($('#J_Total').text());
			// 获取商品单个的总额
			price = parseInt($(this).attr('price'));
			// 商品单个商品总额加上商品总额
			$('#J_Total').text(count+price);

	  }
  });
})


>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
// 减少商品数量
$('.min').click(function(){
	// alert($(this).next().attr('price'));
	// 获取点击后商品数量
	if(parseInt($(this).next().val()) != 0){
		var nowcount = parseInt($(this).next().val())-1;
	}else{
		nowcount = 0;
	}
	
	
	// 获取商品价格
	var price = parseInt($(this).next().attr('price'));
	
	// 重新计算价格
	var newprice = nowcount * price;
	$(this).parent().parent().parent().parent().next().children().text(newprice);
	if($('.checked').attr('checked')) {
		var count = parseInt($('#J_Total').text());
		if(count != 0){
			$('#J_Total').text(count - price);
		}else{
			count = 0;
		}
		
	}
});

// 增加商品数量
$('.add').click(function(){
	// alert($(this).prev().attr('price'));
	// 获取点击后商品数量
	var nowcount = parseInt($(this).prev().val())+1;
	// 获取商品价格
	var price = parseInt($(this).prev().attr('price'));
	// 重新计算价格
	var newprice = nowcount * price;
	$(this).parent().parent().parent().parent().next().children().text(newprice);

	if($('.checked').attr('checked')) {
		var count = parseInt($('#J_Total').text());
		$('#J_Total').text(count + price);
	}
	
});

// 当点击单个单选商品框的时候进行计算商品总额
	$('.checked').click(function(){
		if($(this).attr('checked')) {
			$(this).attr('checked',true);
<<<<<<< HEAD

			// alert($(this).parent().parent().next().next().next().html());
			// 获取要结算的商品
			var pay = $(this).attr('goods')+':'+$('.count').val()+':'+$(this).attr('value');
			if($('#shop').text() == pay){
				$('#shop').text(pay);
			}else{
				$('#shop').text($('#shop').text()+','+pay);
			}
			
=======
			// alert($(this).parent().parent().next().next().next().html());
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
			// 获取商品总金额
			var count = parseInt($('#J_Total').text());
			
			// 获取商品单个的总额
			var price = parseInt($(this).attr('price'));
			// 商品单个商品总额加上商品总额
			$('#J_Total').text(count+price);
		}else{
			$(this).attr('checked',false);
			// 获取商品总金额
			var count = parseInt($('#J_Total').text());
			// 获取商品单个的总额
			var price = parseInt($(this).attr('price'));
			// 商品单个商品总额加上商品总额
			$('#J_Total').text(count-price);

<<<<<<< HEAD

=======
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
			
		}
		
	});



<<<<<<< HEAD
	// 购物车删除方法
	function deleteCar(id) {
		$('.a'+id).html('');
		$.get('/shopCar/deletecar',{'id':id},function(msg){
			console.log(msg);
		},'json')
	}

	$('#J_Go').click(function(){
		// alert($('#shop').text());
		var length = $('.checked:checked').length;
		var pay = '';
		for(i=0;i<length;i++){
			pay = $(".checked:checked").eq(i).attr('goods')+':'+$('.count').eq(i).val()+':'+$('.checked:checked').eq(i).attr('value')+','+pay;
			
			
		}
		
		window.location.href="/home/pay?str="+pay;
		return false;
	})

=======
>>>>>>> b1990139fd74a207cbbfdc7c165186e9f38d0e5d
	
</script>			


@endsection